/*
* $Id: DialogManipulationWin.cpp 152 2010-09-23 18:28:55Z volok-aleksej@yandex.ru $
*
* Copyright 2010 by Alexey Volokitin
* All rights reserved
*
*/
#include "Common/include.h"
#include "DialogManipulationWin.h"
#include "QBWnd.h"
#include "GLWin.h"
#include "ChangeQBWnd.h"
#include "ChangeGLWnd.h"

CDialogManipulationWin::CDialogManipulationWin(CWnd* pParentWnd)
: m_pParent(pParentWnd), m_pWnd(NULL){}
CDialogManipulationWin::~CDialogManipulationWin(){
	if(m_pWnd)
		m_pWnd->Free();
}

void CDialogManipulationWin::SetTypeWin(IDialogWnd::type tp){
	if(m_pWnd){
		m_pWnd->WindowDestroy();
		m_pWnd->Free();
		m_pWnd = NULL;
	}
	m_type = tp;
	WindowCreate();
}

IDialogWnd::type CDialogManipulationWin::GetTypeWin(){
	return m_type;
}

void CDialogManipulationWin::SetId(int nId){
	if(m_pWnd)
		m_pWnd->SetQueenBeeId(nId);
}

void CDialogManipulationWin::WindowCreate(){
	bool bCreate = false;
	QueenBee::change_type type = QueenBee::PARENT;
	switch(m_type)
	{
	case IDialogWnd::INFO:
		m_pWnd = dynamic_cast<IDialogWnd*>(new CQBWnd);
		break;
	case IDialogWnd::INFO_GEN:
		m_pWnd = dynamic_cast<IDialogWnd*>(new CGLWin);
		break;
	case IDialogWnd::NEW:
		bCreate = true;
	case IDialogWnd::CHANGE:
		m_pWnd = dynamic_cast<IDialogWnd*>(new CChangeQBWnd(bCreate));
		break;
	case IDialogWnd::CHANGE_F:
		type = QueenBee::FAMILY;
	case IDialogWnd::CHANGE_P:
		m_pWnd = dynamic_cast<IDialogWnd*>(new CChangeGLWnd(type));
	};
	m_pWnd->WindowCreate(m_pParent);
}

void CDialogManipulationWin::Save(){
	if(m_pWnd)
		m_pWnd->Save();
}

void CDialogManipulationWin::SetSelectedData(unsigned long data){
	if(m_pWnd)
		m_pWnd->SetSelectionData(data);
}

int CDialogManipulationWin::GetId(){
	if(m_pWnd)
		return m_pWnd->GetQueenBeeId();
	return 0;
}

unsigned long CDialogManipulationWin::GetSelectedData(){
	if(m_pWnd)
		return m_pWnd->GetSelectionData();
	return 0;
}
